﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using SqlCon;
using CrystalDecisions.CrystalReports.Engine;
using System.Drawing.Printing;

namespace yfxt.MZYW
{
    public partial class ms_cfcx_dy : Form
    {
        public ms_cfcx_dy()
        {
            InitializeComponent();
        }
        ms_cfcx_mx cfcx_mx;

        SqlConnection conn_001 = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction);
        private void ms_cfcx_dy_Load(object sender, EventArgs e)
        {

            if (conn_001.State != ConnectionState.Open) { conn_001.Open(); }
            cfcx_mx=(ms_cfcx_mx)this.Owner;

           string s_001="select ms_cf01.fphm as fphm,ms_cf01.brxm as brxm ,(case brxz when '0' then '自费' when '1' then '医保' end ) as brxz ,kfrq,ksmc,ygxm " +
                                "from ms_cf01,ms_mzxx,gy_ygdm,gy_ksdm  where ms_cf01.cfhm='"+cfcx_mx.s_temp.ToString()+"'";


           string s_002= "select ypmc,ypgg,ypdw,cdmc,ypdj,ypsl from ms_cf01,ms_cf02,yk_typk,yk_ypcd,yk_cddz  " +
                            " where  ms_cf01.cfsb=ms_cf02.cfsb and yk_typk.ypxh=ms_cf02.ypxh  " +
                            " and yk_typk.ypxh=yk_ypcd.ypxh and yk_cddz.ypcd=yk_ypcd.ypcd  " +
                             "and cfhm=" + cfcx_mx.s_temp.ToString() +
                             "  group by ypmc,ypgg,ypdw,cdmc,ypdj,ypsl";



           ds_cfcx dc = new ds_cfcx();


           SqlDataAdapter da_001 = new SqlDataAdapter(s_001,conn_001);

           SqlDataAdapter da_002 = new SqlDataAdapter(s_002,conn_001);


           da_001.Fill(dc.Tables["dt_01"]);
           da_002.Fill(dc.Tables["dt_02"]);

           MZYW.Cry_cfcx cry = new Cry_cfcx();

           cry.SetDataSource(dc);

           crystalReportViewer1.ReportSource = cry;

             


        }
    }
}
